<?php
use wepay\join\demo\common\SignUtil;
use wepay\join\demo\common\SignUtil2;
use wepay\join\demo\common\DesUtils;
use wepay\join\demo\common\ConfigUtil;
use wepay\join\demo\common\RSAUtils;
use wepay\join\demo\api\WebAsynNotificationCtrl;

/**
 * Class ShopController
 */
class ShopController extends BaseController
{

    /**
     * @return mixed
     * 下载
     */
    public function Down(){
        return $this->view('shop.shop_app_down');
    }

    /**
     * 首页
     */
    public function Index(){
        #获取首页信息
        $info = ShopService::instance()->GetIndex();
        #获取品名
        $select_brand = AdminService::instance()->SelectBrand();
        #获取新闻信息
        $information = ShopService::instance()->GetIndexinformation();
        $index = "index";
        #获取采购信息
       // $purchase = ShopService::instance()->IndexPurchaseResource();
        return $this->view('shop.shop_index')->with(['information'=>$information,'info'=>$info,'select_brand'=>$select_brand,'index_type'=>$index]);
}


    /**
     * 首页搜索下拉
     */
    public function ShopSelect(){

        #接收参数
        $paramObj = new stdClass();
        $paramObj->type_name     =   $this->getParam('type_name');
        return ShopService::instance()->ShopSelect($paramObj);
    }



    /**
     * @return mixed
     * 登录
     */
    public function Login(){
        return $this->view('shop.shop_login');
    }

    /**
     * js登陆验证
     * @return mixed
     */
    public function JsVerifyLogin()
    {

        if (Request::isMethod('POST'))
        {
            #接收参数
            $paramObj = new stdClass();
            $paramObj->username     =   $this->getParam('username');                 //用户名
            $paramObj->pwd          =   $this->getParam('pwd');                      //密码


            #逻辑处理
            if(!empty($paramObj->username)&&empty($paramObj->pwd))
            {
                $data = ShopService::instance()->JsCheckUser($paramObj);
                $rs = empty($data)?0:1;
                return $rs;
            }

            if(!empty($paramObj->pwd))
            {
                $info = ShopService::instance()->JsCheckUser($paramObj);
                $data = ShopService::instance()->JsCheckPwd($paramObj);
                //$data2 = ShopService::instance()->LoginTime($info->user_name,$info->mobile);
               /* if(empty($data2->locktime)){
                    $time = 0;

                }else{
                    $time= $data2->locktime-time();
                }
                if($time<=0){
                    if(empty($data)){
                        if(empty($data2)){
                            $aData=[
                                'user_name' =>  $info->user_name,
                                'mobile'    =>  $info->mobile,
                                'count'     =>  1,
                            ];
                            ShopService::instance()->LoginCount($aData);
                            return 0;
                        }else{
                            if($data2->count==3){
                                $aData=[
                                    'user_name' =>  $data2->user_name,
                                    'mobile'    =>  $data2->mobile,
                                    'count'     =>  $data2->count+1,
                                    'locktime'  =>  time()+600,
                                ];
                                ShopService::instance()->LoginCountA($aData);
                                return 2;
                            }else{
                                $aData=[
                                    'user_name' =>  $data2->user_name,
                                    'mobile'    =>  $data2->mobile,
                                    'count'     =>  $data2->count+1,
                                ];
                                ShopService::instance()->LoginCountA($aData);
                                return 0;
                            }
                        }
                    }else{
                        if(!empty($data2->user_name)){
                            ShopService::instance()->LoginCountDel($data2->user_name);
                            return 1;
                        }else{
                            return 1;
                        }

                    }
                }else{
                    return 2;
                }*/
                if(empty($data)){
                       return 0;
                 }else{
                    return 1;
                }
            }

        }
    }

    /**
     * 登录验证
     * @return mixed
     */
    public function VerifyLogin()
    {
            if (Request::isMethod('POST')) {
                #接受参数
                $paramObj                   =          new stdClass();
                $paramObj->username         =          $this->getParam('username');         //用户名或手机号
                $paramObj->password         =          $this->getParam('password');         //密码
                $paramObj-> index           =          $this->getParam(' index');             //首页登录

               // $paramObj->remember         =          $this->getParam('remember');         //自动登录

                #逻辑处理
                try{
                    ShopService::instance()->VerifyLogin($paramObj);
                    if($paramObj->index){
                        return Redirect::back();
                    }else{
                        return Redirect::to('/');
                    }
                }catch (Exception $e){
                    print $e->getMessage();
                }
            }

    }

    /**
     * 注销用户
     * @author  fyl
     * @date 2016-5-10
     */
    public function Logout()
    {
        #逻辑处理
        try{
            $re = ShopService::instance()->Logout();
            return Redirect::back();
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * @return mixed
     * 注册
     */
    public function Register(){
        return $this->view('shop.shop_register');
    }

    /**
     * 注册入库
     * @author fyl
     * @data 2016-6-20
     */
    public function DeposeRegister()
    {
        #接收参数
        $paramObj                   =          new stdClass();
        $paramObj->mobile           =          $this->getParam('mobile');       //用户名
        $paramObj->password         =          $this->getParam('password');     //密码
        #逻辑处理
        try{
            $data = ShopService::instance()->DeposeRegister($paramObj);
            if($data){
                return Redirect::to('/');
            }
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * @return mixed
     * 重置密码
     */
    public function RetrievePass(){
        return $this->view('shop.shop_retrieve_pass');
    }

    /**
     * @return mixed
     * 重置密码
     */
    public function ModifyPwd(){
        $paramObj                   =          new stdClass();
        $paramObj->mobile         =          $this->getParam('mobile');     //电话
        $paramObj->password         =          $this->getParam('password');     //密码
        #逻辑处理
        try{
            return ShopService::instance()->ModifyPwd($paramObj);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }


    /**
     * @return mixed
     *现货列表
     */
    public function NewResource(){
        $paramObj                    =          new stdClass();
        $paramObj->city              =          $this->getParam('city');                  //城市
        $paramObj->category          =          $this->getParam('category');                   //品类
        $paramObj->brand             =          $this->getParam('brand');                  //品名
        $paramObj->factory           =          $this->getParam('factory');                   //钢厂
        $paramObj->company           =          $this->getParam('company');                  //公司名

        $user_id = session_get(UserEnum::USER_INFO_USER_ID);
        if($user_id){
           $follow_product_id = ShopService::instance()->FollowProductId($user_id);
        }else{
           $follow_product_id = array();
        }
        $new_resource = "new_resource";
        $info = ShopService::instance()->NewResource($paramObj);
        $num = "";
        if(count($info)==0){
            $num = 1;
        }
        //城市
        $hot_city = ShopService::instance()->HotCity();
        //品类
        $category = AdminService::instance()->ShowProductCategory();
      /*  //品名
        if(!empty($paramObj->category)){
            $brand = AdminService::instance()->SelectBrandCategory($paramObj->category);
        }else{
            $brand = AdminService::instance()->SelectBrand();
        }
        //钢厂
        $factory = AdminService::instance()->SelectFactory();*/
        return $this->view('shop.shop_new_resource')->with(['follow_product_id'=>$follow_product_id,'info'=>$info,'hot_city'=>$hot_city,'category'=>$category,'select_city'=>$paramObj->city,'select_category'=>$paramObj->category,'select_brand'=>$paramObj->brand,'select_company'=>$paramObj->company,'select_factory'=>$paramObj->factory,'index_type'=>$new_resource,'num'=>$num]);
    }


    /**
     * @return mixed
     *现货关注
     */
    public function FollowAdd(){
        $paramObj                    =          new stdClass();
        $paramObj->product_id             =          $this->getParam('product_id');
        $paramObj->user_id           =          session_get(UserEnum::USER_INFO_USER_ID);
        return ShopService::instance()->FollowAdd($paramObj);

    }

    /**
     * @return mixed
     *现货关注
     */
    public function FollowDelete(){
        $paramObj                    =          new stdClass();
        $paramObj->product_id             =          $this->getParam('product_id');
        return ShopService::instance()->FollowDelete($paramObj);

    }




    /**
     * 资源单浏览
     */
    public function LookExcel(){
        $filename           =         $this->getParam('filename');
        $res = [];
        Excel::load($filename, function($reader) use( &$res ) {
            $reader = $reader->getSheet(0);
            $res = $reader->toArray();
        });
        return $this->view('shop.shop_preview')->with('excel', $res);
    }

    /**
     * 资源单下载
     */
    public function DownExcel(){
        $filename           =      $this->getParam('filename');
        //$old_name           =      iconv('gb2312','utf-8//TRANSLIT//IGNORE', serialize($this->getParam('old_name')));
        //$old_name           =      $this->getParam('old_name');
        $old_name = "推荐资源单样式"."xls";
        return Response::download($filename);
    }

    /**
     * 多个资源单下载
     */
    public function DownExcelAll(){
        $paramObj                    =          new stdClass();
        $file                        =      explode(',',substr($this->getParam('filename'),0,strrpos($this->getParam('filename'),',')));
        $paramObj->down_num          =       1;
        $paramObj->product_id        =       explode(',',substr($this->getParam('product_id'),0,strrpos($this->getParam('product_id'),',')));
        ShopService::instance()->DownNewResource($paramObj);
        $zip_name = md5(time().rand(99,1000));
        $filename = "resource/SDK/$zip_name.zip";
        $zip = new ZipArchive();
        $zip->open($filename, ZipArchive::CREATE);
        // $zip->addEmptyDir('images'); //增加一个目录的原因是，如果zip包没东西会一直下载，永不停止
        foreach ($file as $value) {
            $fileData = file_get_contents($value);
            if ($fileData) {
                $zip->addFromString($value, $fileData);
            }
        }
        $zip->close();
        return Response::download($filename);
    }


    /**
     * @return mixed
     * 商城列表
     */
    public function Shopping(){
        $paramObj                   =          new stdClass();
        $paramObj->address         =          $this->getParam('address');
        $paramObj->brand           =          $this->getParam('brand');
        $paramObj->spec            =          $this->getParam('spec');
        $paramObj->material       =          $this->getParam('material');
        $paramObj->storage        =          $this->getParam('storage');
        $paramObj->factory        =          $this->getParam('factory');
        $paramObj->product_id        =       $this->getParam('product_id');
        $shopping = "shopping";
        if($paramObj->address||$paramObj->brand||$paramObj->spec||$paramObj->material|| $paramObj->storage||$paramObj->factory ||$paramObj->product_id){
            $address=ShopService::instance()->CitySelect();
            $brand=ShopService::instance()->BrandSelect();
            $storage=ShopService::instance()->StorageSelect();
            $factory=ShopService::instance()->FactorySelect();
            $material=ShopService::instance()->MaterialSelect();
            $data = ShopService::instance()->ShoppingSelect($paramObj);
            $res = ShopService::instance()->ShoppingArray($paramObj);
            return $this->view('shop.shop_shopping')->with(['res'=>$res,'brand'=>$brand,'address'=>$address,'storage'=>$storage,'factory'=>$factory,'material'=>$material,'data'=>$data,'index_type'=>$shopping]);
        }else{
            $address=ShopService::instance()->CitySelect();
            $brand=ShopService::instance()->BrandSelect();
            $storage=ShopService::instance()->StorageSelect();
            $factory=ShopService::instance()->FactorySelect();
            $material=ShopService::instance()->MaterialSelect();
            $data = ShopService::instance()->Shopping();
            $res = ShopService::instance()->ShoppingArray1();
            return $this->view('shop.shop_shopping')->with(['res'=>$res,'brand'=>$brand,'address'=>$address,'storage'=>$storage,'factory'=>$factory,'material'=>$material,'data'=>$data,'index_type'=>$shopping]);
        }

    }
    public function AjaxShopping(){
        $address=ShopService::instance()->CitySelect();
        $brand=ShopService::instance()->BrandSelect();
        $storage=ShopService::instance()->StorageSelect();
        $factory=ShopService::instance()->FactorySelect();
        $material=ShopService::instance()->MaterialSelect();
        $rs['address']=$address;
        $rs['brand']=$brand;
        $rs['storage']=$storage;
        $rs['factory']=$factory;
        $rs['material']=$material;
        return $rs;
    }

    /**
     * @return mixed
     * 四大类检索
     */
    public function ShoppingFour(){

        $paramObj                   =          new stdClass();
        $paramObj->id           =          $this->getParam('id');       //id

        #逻辑处理

        try{
            $data = ShopService::instance()->ShoppingFour($paramObj->id);
            if($data){
                return $this->view('shop.shop_shopping')->with('data',$data);
            }
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
        return $this->view('shop.shop_shopping');

    }
    /**
     * @return mixed
     *
     */
    public function SelectKeyword(){

        $paramObj                   =          new stdClass();
        $paramObj->name           =          $this->getParam('key_word');       //id

        #逻辑处理
            $data = ShopService::instance()->SelectKeyword( $paramObj->name);
                $first= ShopService::instance()->yiji();
                $second= ShopService::instance()->erji($first[0]->cate_id);
                $third= ShopService::instance()->sanji($second[0]->cate_id);

                return $this->view('shop.shop_shopping')->with(['data'=>$data,'first'=>$first,'second'=>$second,'third'=>$third]);

    }

    /**
     * @return mixed
     * 上部检索
     */
 /*   public function IndexKeyword(){

        $paramObj                   =          new stdClass();
        $paramObj->top           =          $this->getParam('top');       //id
        $paramObj->name           =          $this->getParam('name');       //id

        #逻辑处理

        try{
            $data = ShopService::instance()->IndexKeyword( $paramObj->top , $paramObj->name);
            if($data){
                if($paramObj->top == 1){
                    return $this->view('shop.shop_shopping')->with(['data'=>$data,'key_word'=>$paramObj->name,'sort_order'=>'','top'=>1]);
                }else{
                    return $this->view('shop.shop_new_resource')->with(['info'=>$data,'key_word'=>$paramObj->name,'storage'=>'','top'=>2]);
                }
            }
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
        return $this->view('shop.shop_shopping');

    }*/

    /**
     * @return mixed
     * 商城原木板材详情
     */
    public function ShoppingDetails(){

        $paramObj                   =          new stdClass();
        $paramObj->product_id           =          $this->getParam('product_id');       //用户名
        $paramObj->category        =          $this->getParam('category');        //地方
        $index_type     =          'shopping';
        #逻辑处理

       // if($paramObj->category == CateEnum::CATE_TYPE_LOG || $paramObj->category ==CateEnum::CATE_TYPE_DOMESTIC ||$paramObj->category == CateEnum::CATE_TYPE_SLAB){

                $data = ShopService::instance()->ShoppingDetails($paramObj->product_id);
                if($data){
                    $ad_product_id = ShopService::instance()->AdProduct(AdEnum::AD_TYPE_PRODUCT_SHOPPING_DETAILS); //获取推荐商品ID
                    $ad_product_info = ShopService::instance()->AdProductInfo($ad_product_id);             //获取推荐商品信息
                    return $this->view('shop.shop_shopping_details')->with(['data'=>$data,'ad_product'=>$ad_product_info,'index_type'=>$index_type]);
                }

       // }else{
//            try{
//                $data = ShopService::instance()->ShoppingDetails2($paramObj->product_id);
//                if($data){
//                    return $this->view('shop.shop_shopping_details2')->with('data',$data);
//                }
//            }catch(Exception $e){
//                $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
//            }

        }



    /**
     * @return mixed
     * 商城家具工艺品详情
     */
    public function ShoppingDetails2(){

        return $this->view('shop.shop_shopping_details2');

    }

    /**
     * @return mixed
     * 采购列表
     */
    public function PurchaseResource(){
        #逻辑处理
        try{
            $data = ShopService::instance()->PurchaseResource();
            if($data){

                return $this->view('shop.shop_purchase_resource')->with(['data'=>$data]);
            }
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
        return $this->view('shop.shop_purchase_resource');
    }
    /**
     * @return mixed
     * 采购查询
     */
    public function SelectPurchase(){

        $paramObj                   =          new stdClass();
        $paramObj->title           =          $this->getParam('title');       //用户名
        $paramObj->place         =          $this->getParam('place');        //地方
        #逻辑处理
        try{
            $data = ShopService::instance()->SelectPurchase($paramObj);
            if($data){
                $ad_product_id = ShopService::instance()->AdProduct(AdEnum::AD_TYPE_PRODUCT_PURCHASE); //获取推荐商品ID
                $ad_product_info = ShopService::instance()->AdProductInfo($ad_product_id);             //获取推荐商品信息
                return $this->view('shop.shop_purchase_resource')->with(['data'=>$data,'title'=>$paramObj->title,'place'=>$paramObj->place,'ad_product'=>$ad_product_info]);
            }
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
        return $this->view('shop.shop_purchase_resource');

    }
    /**
     * @return mixed
     * 采购添加
     */
    public function AddPurchase()
    {

            $paramObj = new stdClass();
            $paramObj->title = $this->getParam('title');   //商品标题
            $paramObj->spec = $this->getParam('spec');  //规格
            $paramObj->num = $this->getParam('num');      //数量
            $paramObj->unit = $this->getParam('unit');       //单位
            $paramObj->price = $this->getParam('price');         //价格
            $paramObj->place = $this->getParam('place');         //省份
            $paramObj->address = $this->getParam('address');    //详细地址
            $paramObj->sign = $this->getParam('sign');       //备注
            $paramObj->contacts = $this->getParam('contacts');     //联系人
            $paramObj->tell = $this->getParam('tell');            //电话
            $paramObj->company = $this->getParam('company');     //公司
            $paramObj->user_id = session_get(UserEnum:: USER_INFO_USER_ID);
            #逻辑操作

            $data = ShopService::instance()->AddPurchase($paramObj);
            if($data >= 1){

            $rs['code']=1;

            }else{

                $rs['code']=0;
            }

        return $rs;

        }
    /**
     * js注册验证
     * @return int
     */
    public function JsVerifyRegister()
    {
        if (Request::isMethod('POST')) {
            #接收参数
            $paramObj = new stdClass();
            $paramObj->mobile            =       $this->getParam('mobile');                   //联系方式
            $paramObj->news_captcha      =       $this->getParam('news_captcha');             //短信验证码
            $paramObj->captcha           =       $this->getParam('captcha');                  //验证码

            #逻辑处理
            if(!empty($paramObj->captcha))
            {
                $data = ShopService::instance()->JsCheckCaptcha($paramObj);
                return $data;
            }
            if(!empty($paramObj->news_captcha))
            {
                $data = ShopService::instance()->JsCheckNews($paramObj);
                return $data;
            }
            if(!empty($paramObj->mobile))
            {
                $data = ShopService::instance()->JsCheckMobile($paramObj);
                $rs = empty($data)?0:1;
                return $rs;
            }

        }
    }

    /**
     * 短信验证
     * @return string
     */
    public function VerifyNews()
    {
        if(Request::isMethod('POST')){
            #接收参数
            $paramObj = new stdClass();
            $paramObj->mobile            =       $this->getParam('mobile');                  //联系方式

            if(!empty($paramObj->mobile))
            {
                $data = ShopService::instance()->VerifyNews($paramObj);
                return $data;
            }
        }
    }

    /**
     * @return mixed
     * 资讯列表    */
    public function InformationList(){
        $paramObj = new stdClass();
        $paramObj->cate            =       $this->getParam('cate');                  //资讯类型
        //$index_type = 'information';
        try{
            $data = ShopService::instance()->InformationList($paramObj->cate);

                $ad_product_id = ShopService::instance()->AdProduct(AdEnum::AD_TYPE_PRODUCT_INFORMATION); //获取推荐商品ID
                $ad_product_info = ShopService::instance()->AdProductInfo($ad_product_id);             //获取推荐商品信息
                return $this->view('shop.shop_information_list')->with(['data'=>$data,'ad_product'=>$ad_product_info]);

        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }   return $this->view('shop.shop_information_list');

    }
    /**
     * @return mixed
     * 资讯详情    */
    public function InformationDetails(){
        $paramObj = new stdClass();
        $paramObj->id            =       $this->getParam('id');                  //id
        $index_type = 'information';
        try{
            $data = ShopService::instance()->InformationDetails($paramObj->id);

            if($data){
//                $ad_product_id = ShopService::instance()->AdProduct(AdEnum::AD_TYPE_PRODUCT_INFORMATION_DETAILS); //获取推荐商品ID
//                $ad_product_info = ShopService::instance()->AdProductInfo($ad_product_id);             //获取推荐商品信息
                 return $this->view('shop.shop_article_details')->with(['data'=>$data,'index_type'=>$index_type]);
            }
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }
    /**
     * 发布定制单
     * @author fyl
     * @data  2016-9-06
     */
    public function PublishCustomize()
    {
        #收集信息
        $paramObj                       =          new stdClass();
       // $paramObj->contact            =          $this->getParam('contact');                            //联系人
        $paramObj->mobile               =          $this->getParam('mobile');                             //联系方式
        $paramObj->brand                =          $this->getParam('brand');                              //品名
        $paramObj->province             =          $this->getParam('province');                           //省份
        $paramObj->city                 =          $this->getParam('city');                               //城市
        $paramObj->description          =          $this->getParam('description');                        //定制需求
        #逻辑操作
            $data = ShopService::instance()->PublishCustomize($paramObj);
            return $data;

    }
    //PC端京东支付
    public function  JdPay(){

        $param = array();
        $param["currency"]              = "CNY";
        $param["merchantNum"]           = "110173565001";// 22294531
        $param["merchantRemark"]        = "服务平台";
        $param["notifyUrl"]             = "http://www.ganglianw.com/Api/notify_web";
        $param["successCallbackUrl"]    = "http://www.ganglianw.com/jd_pay_success";//$_POST["successCallbackUrl"];
       // $param["tradeAmount"]           = $_POST["tradeAmount"]*100;
        $param["tradeAmount"]="1";
       // $param["tradeDescription"]      = $_POST["tradeName"];
        $param["tradeDescription"]="";
       // $param["tradeName"]             = $_POST["tradeName"];
        $param["tradeName"]="钢材";
       // $param["tradeNum"]              = $_POST["tradeNum"].session_get(UserEnum::USER_INFO_USER_ID);;
        $param["tradeNum"]=$_SESSION['array']['trade_num'];
      //  $param["ip"]                    = $_POST["ip"];
        $param["ip"]="127.0.0.1";
        $param["tradeTime"]             = date('Y-m-d H:i:s',$_SESSION['array']['order_time']);
        $param["version"]               = "1.1.5";
        $param["token"]                 = "";
        $specialJson = array();
        $specialJson["specBankCardNo"] =$_POST['BandCard'];
        $param["specifyInfoJson"] = json_encode($specialJson);
        $sign = SignUtil2::signWithoutToHex($param);
        $param["merchantSign"] = $sign;
        $_SESSION['tradeInfo'] = $param;

        //跳转到自动提交页
        return $this->view('shop.shop_paysubmit');
    }

    public function JdPayFirst(){
        $paramObj = new stdClass();
        $paramObj->order_id            =       $this->getParam('order_id');
        $data = ApiService::instance()->SelectOrder($paramObj->order_id );
        $data['order_id']=$paramObj->order_id;
        $_SESSION['array'] = $data;
        // $config = Config::get("jd_pay");
        // $serverPayUrl = $config["serverPayUrl"];
        return $this->view('shop.shop_user_cashier');
    }

    /**
     * @return mixed
     * 采购保障
     */
    public function PurchaseGuarantee(){
        return $this->view('shop.shop_purchase_guarantee');
    }

    /**
     * @return mixed
     * 关于
     */
    public function FootAbout(){
        return $this->view('shop.shop_foot_about');
    }

    /**
     * @return mixed
     * 关于
     */
    public function FootContactUs(){
        return $this->view('shop.shop_foot_contact_us');
    }

    /**
     * @return mixed
     * 关于
     */
    public function FootLav(){
        return $this->view('shop.shop_foot_lav');
    }

    /**
     * @return mixed
     * 常见问题
     */
    public function FootDl(){
        $re            =       $this->getParam('re');
        return $this->view('shop.shop_foot_problem')->with('re',$re);
    }
    /**
     *
     * 成功跳转页面
     */
    public function JdPaySuccess(){
        $trade_num            =       $this->getParam('tradeNum');
        $order = ShopService::instance()->SelectOrderId($trade_num);
        $data = ShopService::instance()->OrderDetail($order->order_id);
        return $this->view('shop.user_order_pay_succ')->with('data', $data);
    }

    /**
     * @return mixed
     * 移动端
     */
    public function Phone(){

        return $this->view('shop.shop_phone')->with('index_type','phone');
    }

    /**
     * @return int
     * @throws Exception
     * 反馈信息
     */
    public function Opinion(){
        $paramObj = new stdClass();
        $paramObj->content              =           $this->getParam('content');
        $paramObj->mobile               =           $this->getParam('mobile');
        return  ShopService::instance()->SendFeedback($paramObj);

    }

    /**
     * banner专题
     */
    public function BannerSpecial(){
        return $this->view('shop.shop_banner_special');
    }


    public function AjaxNewResource(){
        $paramObj = new stdClass();
        $paramObj->select_category              =           $this->getParam('select_category');
       if(empty($paramObj->select_category)){
           $brand=ShopService::instance()->BrandSelect();
       }else{
           $brand = AdminService::instance()->SelectBrandCategory($paramObj->select_category);
       }

        $factory=ShopService::instance()->FactorySelect();
        $rs['brand']=$brand;
        $rs['factory']=$factory;
        return $rs;
    }



}
